package com.vast.ui.component.toolbar;

import org.eclipse.jface.action.Action;

import com.vast.ui.panel.fullcolorled.Activator;
import com.vast.ui.panel.fullcolorled.views.ViewPart;


public abstract class ToolBarAction extends AbstractToolBarAction {
	private final Action          startAction;
	private final Action          stopAction;
	private final Action          addAction;
	private final Action          deleteAction;
	
	public ToolBarAction(final ViewPart view) {
		super(view);
		startAction = new Action() {
			public void run() {
				//openConnection();
				startAction();
			}
		};
		startAction.setEnabled(true);
		startAction.setToolTipText("Open Socket Connection");
		startAction.setImageDescriptor(Activator.getDefault().getImageRegistry().getDescriptor("START_ENABLED"));
		
		stopAction = new Action() {
			public void run() {
				//closeConnection();
				stopAction();
			}
		};
		stopAction.setEnabled(false);
		stopAction.setToolTipText("Close Socket Connection");
		stopAction.setImageDescriptor(Activator.getDefault().getImageRegistry().getDescriptor("STOP_ENABLED"));
		
		addAction = new Action() {
			public void run() {
				addAction();
			}
		};
		addAction.setEnabled(true);
		addAction.setToolTipText("Add Line");
		addAction.setImageDescriptor(Activator.getDefault().getImageRegistry().getDescriptor("ADD"));
		
		deleteAction = new Action() {
			public void run() {
				deleteAction();
			}
		};
		deleteAction.setEnabled(true);
		deleteAction.setToolTipText("Delete Line");
		deleteAction.setImageDescriptor(Activator.getDefault().getImageRegistry().getDescriptor("DELETE"));
		
		toolbar.add(startAction);
		toolbar.add(stopAction);
		toolbar.add(addAction);
		toolbar.add(deleteAction);
	}

	public abstract void startAction();
	public abstract void stopAction();
	public abstract void addAction();
	public abstract void deleteAction();
	
	public void setStartActionEnable() {
		// TODO Auto-generated method stub
		startAction.setEnabled(true);
		stopAction.setEnabled(false);
	}

	public void setStopActionEnable() {
		// TODO Auto-generated method stub
		startAction.setEnabled(false);
		stopAction.setEnabled(true);
	}

}
